import request from '@/utils/request'

//获取结算（优惠）信息，补货下订单用
export function replenSettlement(data) {
	const data2 = {
	  ...data,
	};
	delete data2.items;
	for (let i = 0; i < data.items.length; i++) {
	  data2[encodeURIComponent('items[' + i + '' + '].specsId')] = data.items[i].specsId + '';
	  data2[encodeURIComponent('items[' + i + '' + '].count')] = data.items[i].count + '';
	  if (data.items[i].cartId) {
	    data2[encodeURIComponent('items[' + i + '' + '].cartId')] = data.items[i].cartId + '';
	  }
	}
	const queryString = Object.keys(data2)
	  .map((key) => key + '=' + data2[key])
	  .join('&');
	return request({
		url: `/beer/order/settlement?${queryString}`,
		method: 'GET',
	})
}

//获取补货订单售后
export function replenAfterSale(data) {
	return request({
		url: '/beer/after-sale/page',
		method: 'GET',
		data
	})
}